import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { TechnicianDispatchApi } from '#/api/spa/technicians/dispatch';

import { getDictOptions, getRangePickerDefaultProps } from '#/utils';
import { DICT_SPA_TYPE } from '#/utils/dictSpa';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'dispatchCode',
      label: '派工编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入派工编码',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师',
      },
    },
    {
      fieldName: 'bookingId',
      label: '预约ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预约ID',
      },
    },
    {
      fieldName: 'handCardId',
      label: '手牌ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入手牌ID',
      },
    },
    {
      fieldName: 'userId',
      label: '客户用户ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户用户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'serviceName',
      label: '服务名称',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务名称',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'roomNumber',
      label: '房间号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入房间号',
      },
    },
    {
      fieldName: 'dispatchType',
      label: '派工类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择派工类型',
      },
    },
    {
      fieldName: 'scheduledStartTime',
      label: '计划开始时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'scheduledEndTime',
      label: '计划结束时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'actualStartTime',
      label: '实际开始时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'actualEndTime',
      label: '实际结束时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'durationMinutes',
      label: '服务时长(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'acceptTime',
      label: '接单时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'completionNotes',
      label: '完成备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入完成备注',
      },
    },
    {
      fieldName: 'qualityScore',
      label: '质量评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入质量评分',
      },
    },
    {
      fieldName: 'customerFeedback',
      label: '客户反馈',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户反馈',
      },
    },
    {
      fieldName: 'dispatcherId',
      label: '派工人ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入派工人ID',
      },
    },
    {
      fieldName: 'dispatcherName',
      label: '派工人姓名',
      component: 'Input',
      componentProps: {
        placeholder: '请输入派工人姓名',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'serviceCategory',
      label: '服务分类',
      component: 'Input',
      componentProps: {
        placeholder: '请输入服务分类',
      },
    },
    {
      fieldName: 'priorityLevel',
      label: '优先级',
      component: 'Input',
      componentProps: {
        placeholder: '请输入优先级',
      },
    },
    {
      fieldName: 'estimatedDuration',
      label: '预估时长(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估时长(分钟)',
      },
    },
    {
      fieldName: 'technicianSelfRating',
      label: '技师自评分数',
      component: 'Input',
      componentProps: {
        placeholder: '请输入技师自评分数',
      },
    },
    {
      fieldName: 'supervisorRating',
      label: '主管评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入主管评分',
      },
    },
    {
      fieldName: 'overallQualityScore',
      label: '综合质量评分',
      component: 'Input',
      componentProps: {
        placeholder: '请输入综合质量评分',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'dispatchCode',
      label: '派工编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入派工编码',
      },
    },
    {
      fieldName: 'technicianId',
      label: '技师名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师名称',
      },
    },
    {
      fieldName: 'bookingId',
      label: '预约单号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预约单号',
      },
    },
    {
      fieldName: 'handCardId',
      label: '手牌号码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入手牌号码',
      },
    },
    {
      fieldName: 'userId',
      label: '客户用户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户用户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'serviceId',
      label: '服务ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务ID',
      },
    },
    {
      fieldName: 'serviceName',
      label: '服务名称',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务名称',
      },
    },
    {
      fieldName: 'roomId',
      label: '房间ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入房间ID',
      },
    },
    {
      fieldName: 'roomNumber',
      label: '房间号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入房间号',
      },
    },
    {
      fieldName: 'dispatchType',
      label: '派工类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择派工类型',
      },
    },
    {
      fieldName: 'scheduledStartTime',
      label: '计划开始时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'scheduledEndTime',
      label: '计划结束时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'actualStartTime',
      label: '实际开始时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'actualEndTime',
      label: '实际结束时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'durationMinutes',
      label: '服务时长(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务时长(分钟)',
      },
    },
    {
      fieldName: 'status',
      label: '状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择状态',
      },
    },
    {
      fieldName: 'acceptTime',
      label: '接单时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'completionNotes',
      label: '完成备注',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入完成备注',
      },
    },
    {
      fieldName: 'qualityScore',
      label: '质量评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入质量评分',
      },
    },
    {
      fieldName: 'customerFeedback',
      label: '客户反馈',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户反馈',
      },
    },
    {
      fieldName: 'dispatcherId',
      label: '派工人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入派工人ID',
      },
    },
    {
      fieldName: 'dispatcherName',
      label: '派工人姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入派工人姓名',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'serviceCategory',
      label: '服务分类',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入服务分类',
      },
    },
    {
      fieldName: 'priorityLevel',
      label: '优先级',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入优先级',
      },
    },
    {
      fieldName: 'estimatedDuration',
      label: '预估时长(分钟)',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预估时长(分钟)',
      },
    },
    {
      fieldName: 'technicianSelfRating',
      label: '技师自评分数',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入技师自评分数',
      },
    },
    {
      fieldName: 'supervisorRating',
      label: '主管评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入主管评分',
      },
    },
    {
      fieldName: 'overallQualityScore',
      label: '综合质量评分',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入综合质量评分',
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<TechnicianDispatchApi.TechnicianDispatch>['columns'] {
  return [
    // {
    //   field: 'id',
    //   title: '主键ID',
    //   minWidth: 120,
    // },
    {
      field: 'dispatchCode',
      title: '派工编码',
      minWidth: 120,
    },
    {
      field: 'technicianId',
      title: '技师名称',
      minWidth: 120,
    },
    {
      field: 'bookingId',
      title: '预约ID',
      minWidth: 120,
    },
    {
      field: 'handCardId',
      title: '手牌ID',
      minWidth: 120,
    },
    {
      field: 'userId',
      title: '客户用户ID',
      minWidth: 120,
    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 120,
    },
    {
      field: 'serviceId',
      title: '服务ID',
      minWidth: 120,
    },
    {
      field: 'serviceName',
      title: '服务名称',
      minWidth: 120,
    },
    {
      field: 'roomId',
      title: '房间ID',
      minWidth: 120,
    },
    {
      field: 'roomNumber',
      title: '房间号',
      minWidth: 120,
    },
    {
      field: 'dispatchType',
      title: '派工类型',
      minWidth: 120,
    },
    {
      field: 'scheduledStartTime',
      title: '计划开始时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'scheduledEndTime',
      title: '计划结束时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'actualStartTime',
      title: '实际开始时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'actualEndTime',
      title: '实际结束时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'durationMinutes',
      title: '服务时长(分钟)',
      minWidth: 120,
    },
    {
      field: 'status',
      title: '状态',
      minWidth: 120,
    },
    {
      field: 'acceptTime',
      title: '接单时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'completionNotes',
      title: '完成备注',
      minWidth: 120,
    },
    {
      field: 'qualityScore',
      title: '质量评分',
      minWidth: 120,
    },
    {
      field: 'customerFeedback',
      title: '客户反馈',
      minWidth: 120,
    },
    {
      field: 'dispatcherId',
      title: '派工人ID',
      minWidth: 120,
    },
    {
      field: 'dispatcherName',
      title: '派工人姓名',
      minWidth: 120,
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'serviceCategory',
      title: '服务分类',
      minWidth: 120,
    },
    {
      field: 'priorityLevel',
      title: '优先级',
      minWidth: 120,
    },
    {
      field: 'estimatedDuration',
      title: '预估时长(分钟)',
      minWidth: 120,
    },
    {
      field: 'technicianSelfRating',
      title: '技师自评分数',
      minWidth: 120,
    },
    {
      field: 'supervisorRating',
      title: '主管评分',
      minWidth: 120,
    },
    {
      field: 'overallQualityScore',
      title: '综合质量评分',
      minWidth: 120,
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
